Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/implicit deregistration #107

Merged
merged 18 commits into from
Oct 28, 2023
Merged

Feature/implicit deregistration #107

merged 18 commits into from
Oct 28, 2023

Conversation

YouShengLiu
Copy link
Contributor

Implement a callback function to handle the Deregistration Notify form UDM which is step 14 of the general registration procedure.


if smContext.AccessType() == deregData.AccessType {
var problemDetails *models.ProblemDetails
problemDetails, err = consumer.SendReleaseSmContextRequest(ue, smContext, nil, "", nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SendReleaseSmContextRequest() needs to read the attribute of the ue, it will occur the concurrent read/write if another ngap/nas message for the same ue is sent to AMF.
Please help to check do we need a mutex lock here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, it seems like the behavior of AMF in this case is the same with gmm_common.RemoveAmfUe(amfUe, false).
@iamelisahi @YouShengLiu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SendReleaseSmContextRequest() needs to read the attribute of the ue, it will occur the concurrent read/write if another ngap/nas message for the same ue is sent to AMF.
Please help to check do we need a mutex lock here.

SendReleaseSmContextRequest() will only use the ue.TimeZone and smContext.
Since the smContext is stored in ue.SmContextList and protected under the sync.Map, we can leave it alone.
However, the ue.TimeZone is not protected, it may need mutex lock to protect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, it seems like the behavior of AMF in this case is the same with gmm_common.RemoveAmfUe(amfUe, false).

Yes, it is very similar but there are still some differences.

According to the TS 29.503 - Table 6.2.6.2.7-1: Definition of type Amf3GppAccessRegistrationModification - backupAmfInfo:

This IE shall be included if the NF service consumer is an AMF and the AMF supports the AMF management without UDSF for the Modification of the BackupAmfInfo.
The UDM uses this attribute to do an NRF query in order to invoke later services in a backup AMF, e.g. Namf_EventExposure

We think we should provide the BackupAmfInfo but the UeCmDeregistration() didn't.
Should we need to modify UeCmDeregistration(), e.g. add one more parameter to decide if it needs to put the BackupAmfInfo into Amf3GppAccessRegistrationModification?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YouShengLiu

Yes, it is very similar but there are still some differences.

Is it possible to reuse the duplicated part?

We think we should provide the BackupAmfInfo but the UeCmDeregistration() didn't.
Should we need to modify UeCmDeregistration(), e.g. add one more parameter to decide if it needs to put the BackupAmfInfo into Amf3GppAccessRegistrationModification?

I think you are right, please help to fill the BackupAmfInfo.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does spec mention to use old amf as the backup amf? I think it's strange to notify UDM that the backup amf of e.g. amf1 is amf1 itself😂 Backup AMF may be a pre-config field to this AMF's config in my opnion.

Copy link
Contributor Author

@YouShengLiu YouShengLiu Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spec didn't mention using old AMF as the backup AMF directly. I was thinking that the old AMF could be one of the backup AMFs when the new AMF is serving the UE.
I checked the data stored in the database, the serving AMF was the new AMF, and the old AMF became the backup AMF:

{
  "_id": {
    "$oid": "650059c26b8b38f7f8ab93dc"
  },
  "ueId": "imsi-2089300007487",
  "amfInstanceId": "faf609ad-2cbd-4082-bf41-7a554e4aa626",
  "imsVoPs": "HOMOGENEOUS_NON_SUPPORT",
  "deregCallbackUri": "http://127.0.0.19:8000/namf-callback/v1/amf-implicit-deregistration/imsi-2089300007487",
  "initialRegistrationInd": true,
  "guami": {
    "amfId": "cafe01",
    "plmnId": {
      "mcc": "208",
      "mnc": "93"
    }
  },
  "ratType": "",
  "backupAmfInfo": [
    {
      "backupAmf": "AMF",
      "guamiList": [
        {
          "amfId": "cafe00",
          "plmnId": {
            "mcc": "208",
            "mnc": "93"
          }
        }
      ]
    }
  ],
  "purgeFlag": true
}

I think it's strange to notify UDM that the backup amf of e.g. amf1 is amf1 itself😂 Backup AMF may be a pre-config field to this AMF's config in my opinion.

I agree that using pre-config is a better solution.

Copy link
Contributor

@ianchen0119 ianchen0119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed,
AMF should not send UECM_DEREG to UDM when AMF received the dereg_notification from UDM.


gmm_common.RemoveAmfUe(ue, false)
// TODO: Currently only consider the 3GPP access type
if !ue.UeCmRegistered[models.AccessType__3_GPP_ACCESS] {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will 3gpp and non-3gpp have different behavior here? I think a better implementation here is to remove the context according to different access type (which is specified during context transfer procedure), but I understand it seems that currently we can only remove the complete AmfUe context (3gpp+non-3gpp). In this case, I don't quite understand why non-3gpp is excluded here😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we are not sure how to deal with the non-3GPP case, we temporarily considered the 3GPP case.

// TS 23.502 - 4.2.2.2.2 General Registration
// The old AMF should clean the UE context
// The AMF also unsubscribes with the UDM using Nudm_SDM_Unsubscribe service operation.
err = gmm_common.PurgeSubscriberData(ue, deregData.AccessType)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For SDMUnsubscribe in PurgeSubscriberData, 23.502 4.2.2.2.2 step 14.e mentioned that
If old AMF does not have UE context for another access type (i.e. non-3GPP access), the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe
Should this be checked here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the TS 23.502 - 4.2.2.3.3 Network-initiated Deregistration,

[Conditional] If the Deregistration procedure is triggered by UDM (Step 1), the AMF acknowledges the Nudm_UECM_DeRegistrationNotification to the UDM. The AMF also unsubscribes with the UDM using Nudm_SDM_Unsubscribe service operation.

However, it seems that we should also consider whether old AMF have UE context for non-3GPP access.
I am not sure which elements in the AmfUe context belong to non-3GPP, maybe you can enlighten me. :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, contexts in AmfUe without map[models.AccessType]Xxx are contexts shared by both 3gpp and non-3gpp. In other words, contexts with map[models.AccessType]Xxx may indicate the existance of non-3gpp contexts.
I think one way to judge whether amf has non-3gpp access may be checking the existence of ameUe.State[N3GPP], but that requires refactoring for amfUe.init() since it initializes ameUe.State[N3GPP] with Deregistered state instead of nil.😂

I think this can be added as TODO comment if that may take time to achieve currently, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to R15 TS 23.502 - 4.2.2.2.2 - 14e,

The Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe.

I think we can add a TODO comment here.

err = gmm_common.PurgeSubscriberData(ue, deregData.AccessType)
if err != nil {
logger.CallbackLog.Errorf("Purge subscriber data Error: %v", err)
}
Copy link

@ss920386 ss920386 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original RemoveAmfUe at dereg when notifyNf is true also considers AMPolicyControlDelete. Should AMPolicyControlDelete be included here according to TS 23.502 4.2.2.2.2 14d?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the description in R15 - TS 23.502 - 4.2.2.2.2 - 14d and I am not sure if we need to delete AmPolicy here.
Based on my understanding of implicitly deregistering AMF, the goal of it is only to remove the UE context from old AMF rather than deregister the UE from the network.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I think that's step 20. in R15.

  1. [Conditional] old AMF to (V-)PCF: AMF-Initiated Policy Association Termination.
    If the old AMF previously initiated a Policy Association to the PCF, and the old AMF did not transfer the PCF
    ID(s) to the new AMF (e.g. new AMF is in different PLMN), the old AMF performs an AMF-initiated Policy
    Association Termination procedure, as defined in clause 4.16.3.2, to delete the association with the PCF.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UE_INITIAL_REGISTRATION and SUBSCRIPTION_WITHDRAW, it is fine to do AMF-Initiated Policy Association Termination directly. However, if it is REGISTRATION_AREA_CHANGE, it is possible that the new AMF reuses the associated PCF ID, which hence should not be terminated.
R15 spec mentioned the condition:

If the old AMF previously initiated a Policy Association to the PCF, and the old AMF did not transfer the PCF
ID(s) to the new AMF

R16 has clearer instructions:

If the old AMF has established an AM Policy Association and a UE Policy Association with the PCF(s), and the
old AMF did not transfer the PCF ID(s) to the new AMF (e.g. new AMF is in different PLMN), the old AMF
performs an AMF-initiated Policy Association Termination procedure, as defined in clause 4.16.3.2, and
performs an AMF-initiated UE Policy Association Termination procedure, as defined in clause 4.16.13.1. In
addition, if the old AMF transferred the PCF ID(s) in the UE context but the new AMF informed in step 10 that
the AM Policy Association information and UE Policy Association information in the UE context will not be
used then the old AMF performs an AMF-initiated Policy Association Termination procedure, as defined in
clause 4.16.3.2, and performs an AMF-initiated UE Policy Association Termination procedure, as defined in
clause 4.16.13.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For UE_INITIAL_REGISTRATION and SUBSCRIPTION_WITHDRAW, it is fine to do AMF-Initiated Policy Association Termination directly. However, if it is REGISTRATION_AREA_CHANGE, it is possible that the new AMF reuses the associated PCF ID, which hence should not be terminated.

I agree with that, however, free5GC currently doesn't utilize the PCF ID to select the PCF, therefore, I leave the TODO comments for it.
Should we complete the feature (searching PCF by using PCF ID) in this PR or open another PR for this feature?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine to leave for a new PR. Lastly, please help to change the TODO comments (// TODO: It also needs to check if the PCF ID is tranfered to new AMF...) to the followings:

// For UE_INITIAL_REGISTRATION and SUBSCRIPTION_WITHDRAW, do AMF-Initiated Policy Association Termination directly.
// TODO: For REGISTRATION_AREA_CHANGE, old AMF performs an AMF-initiated Policy Association Termination 
// procedure if the old AMF has established an AM Policy Association and a UE Policy Association with the PCF(s), 
// and the old AMF did not transfer the PCF ID(s) to the new AMF. (Ref: TS 23.502 - 4.2.2.2.2) 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

ue.SdmSubscriptionId = ""
}

if doUecmDereg {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this dereg the new registered UE after new AMF's when the dereg reason is UE_INITIAL_REGISTRATION?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should UE_INITIAL_REGISTRATION also exclude UeCmDereg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, if the reason is UE_INITIAL_REGISTRATION the consumer NF should be during the initial registration procedure. Therefore I think the consumer NF should execute the UECM Deregistration.
For example, let's say the new AMF has completed the UECM Registration but has not completed the initial registration procedure yet. If it receives the deregistration notification from UDM, I think the reason may be UE_INITIAL_REGISTRATION.
Another example is that the old AMF has completed the initial registration procedure and the new AMF is during the initial registration procedure. The UDM sends a deregistration notification with the reason SUBSCRIPTION_WITHDRAWN to the old AMF.
If I was wrong, please correct me.

Copy link

@ss920386 ss920386 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to 23.502 4.2.2.2.2, I think only the old AMF receives UECM_DeregistrationNotification during the initial registration, and I think UE_INITIAL_REGISTRATION is the only dereg reason that fits it🤔. (Or did you see any other parts of specs mentioning this part?)
image

For the reason SUBSCRIPTION_WITHDRAWN, I saw it mentioned in 4.2.2.3.3 Network-initiated Deregistration.

  1. [Conditional] If the UDM wants to request the immediate deletion of a subscriber's RM contexts and PDU
    Sessions, the UDM shall send a Nudm_UECM_DeregistrationNotification (SUPI, Access Type, Removal
    Reason) message with Removal Reason set to Subscription Withdrawn to the registered AMF. The Access Type
    may indicate 3GPP Access, non-3GPP Access or both.

Indeed, I'm not quite sure whether the cited parts include all cases for SUBSCRIPTION_WITHDRAWN, so feel free to open more discussions if you have any concerns🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @YouShengLiu @ss920386
I think @ss920386's concern is right, those service operations should be mutually exclusive.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that is the case, another concern is that if UDM does deregister the AMF when it sends UECM_DeregistrationNotification in our UDM implementation. (It is possible that our UDM simply sents UECM_DeregistrationNotification to AMF without handling the related contexts.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the current implementation in UDM, it will use the Amf3GppAccessRegistration from the new AMF to replace the Amf3GppAccessRegistration from the old AMF.
Then, the UDM will send UECM_DeregistrationNotification to AMF.
Amf3GppAccessRegistration is the context related to the Nudm_UECM for AMF registration for 3GPP access.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YouShengLiu How about SUBSCRIPTION_WITHDRAW?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the current UDM sends the dereg notification with the reason SUBSCRIPTION_WITHDRAW, based on our discussion, I think it should be modified to UE_INITIAL_REGISTRATION.
Therefore, the current UDM would not have the possibility to send the dereg notification with the reason SUBSCRIPTION_WITHDRAW.
As for further development, we may implement another API to handle this situation (e.g. OAM) or it will be triggered from UDR when the subscription data is removed.

{
"AmfHandleDeregistrationNotification",
strings.ToUpper("Post"),
"/amf-implicit-deregistration/3gpp-access/:ueid",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modify as below:

/deregistration/:access/:ueid

add query parameter type=implicit

real URI will be like:
{URL}/deregistration/3gpp/imsi-208930000000001?type=implicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot the request body of the deregistration notification contains the access type.
Therefore, It should not put the access type into the URI.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YouShengLiu
Sorry, no need use type queryParam, amf can determine to do implicit dereg by deregReason in DeregistrationData.


if doUecmDereg {
// Use old AMF as the backup AMF
backupAmfInfo := models.BackupAmfInfo{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now there is no config for backup amf, so don't fill backup amf info to UDM for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will remove it.

ue.GmmLog.Errorf("Release SmContext Failed Problem[%+v]", problemDetails)
} else if err != nil {
ue.GmmLog.Errorf("Release SmContext Error[%v]", err.Error())
if deregType == "implicit" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implicit and explicit dereg procedures are almost same, only difference is nas msg sent in explicit dereg. The procedures before ue.Remove() can move out this if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implicit and explicit dereg procedures are almost same, only difference is nas msg sent in explicit dereg. The procedures before ue.Remove() can move out this if.

OK

// TS 23.502 - 4.2.2.2.2 General Registration - 14e
// TODO: (R16) If old AMF does not have UE context for another access type (i.e. non-3GPP access),
// the Old AMF unsubscribes with the UDM for subscription data using Nudm_SDM_unsubscribe
if ue.SdmSubscriptionId != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianchen0119 check udm implementation to make sure old amf will not unsubscribe new amf's subscription


// TS 23.502 - 4.2.2.2.2 General Registration - 20 AMF-Initiated Policy Association Termination
// For UE_INITIAL_REGISTRATION and SUBSCRIPTION_WITHDRAW, do AMF-Initiated Policy Association Termination directly.
if ue.PolicyAssociationId != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianchen0119 check pcf implementation to make sure old amf will not unsubscribe new amf's ampolicy association

YouShengLiu and others added 6 commits October 28, 2023 16:02
* It is a callback function for handling the Deregistration Notify from UDM.
* if amfue has completed UeCmRegisteration, RemoveAmfUe should be done in AmfHandleDeregistrationNotification.
* currently only consider the 3GPP access type
* Use API to replace the duplicate code.
* Add BackupAmfInfo to the AmfUe structure for UeCmDeregistration.
* Expose the function "PurgeSubscriberData" from "gmm/common" package for purging the subscriber data with the specified access type.
* (R15) Old AMF always execute Nudm_SDM to unsubscribes with UDM. (don't consider access type)
* Old AMF will determine whether to execute Nudm_UECM de-registration with UDM based on the dereg cause.
* Old AMF will delete the AM policy with PCF
* Modify DeregCallbackUri to differentiate the access type.
* Modify the file name for consistency.
* Modify the structure of the handler function.
* Add query parameter to differential the deregistration type is implicit or explicit.
- Remove the query parameter
- DeregistrationNotifcation and UECM_Deregistration are mutually exclusive
@tim-ywliu tim-ywliu merged commit aebc9fc into free5gc:main Oct 28, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants